using ASP;
using HoWave.Common;
using HoWave.Data;
using HoWave.Web;
using HoWave.Web.Shop;
using System;
using System.Collections;
using System.Data;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using ucApi;
public class Passport_UserReg : Shop, IRequiresSessionState
{
	protected HtmlHead Head1;
	protected UserControls_cmpy_Top Top1;
	protected RadioButtonList RadioMemberList;
	protected HtmlTableRow tabMember;
	protected TextBox H_UserName;
	protected TextBox H_UserPassword;
	protected TextBox RePassword;
	protected Panel ShowPasswordCheck;
	protected TextBox H_UserEmail;
	protected DropDownList H_UserQuestion;
	protected TextBox H_UserAnswer;
	protected Literal RegCheckQuestion;
	protected TextBox ReqCheckAnswer;
	protected PlaceHolder RegProtected;
	protected RadioButtonList H_UserSex;
	protected TextBox CheckCode;
	protected HtmlTableRow EnableRegCheckCode;
	protected HtmlInputCheckBox read_agreement;
	protected Button RegSubmitButton;
	protected HiddenField H_Other;
	protected HiddenField H_ComeUrl;
	protected UserControls_CMYP_Foot Foot1;
	protected HtmlForm form1;
	private UserBll _user;
	private MessageBll _msg;
	private Email _email;
	private MobileMessage _mmsg;
	private int isOutWebSite = 0;
	private string m_ComeUrl = "";
	private string RegUserName;
	private string RegPassword;
	private string O_RegPassword;
	private string RegQuestion;
	private string O_RegAnswer;
	private string RegAnswer;
	private string RegEmail;
	private int RegSex;
	private string Regpwd;
	private string RegOther = "";
	private string MobilePhone = "";
	private string fields = "";
	private string fields_infr = "";
	private IDbDataParameter[] param = null;
	private IDbDataParameter[] param_infr = null;
	private ArrayList al = new ArrayList();
	private ArrayList al_infr = new ArrayList();
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected UserBll m_User
	{
		get
		{
			UserBll user;
			if (this._user == null)
			{
				this._user = new UserBll(this.conn);
				user = this._user;
			}
			else
			{
				user = this._user;
			}
			return user;
		}
	}
	protected MessageBll m_msg
	{
		get
		{
			MessageBll msg;
			if (this._msg == null)
			{
				this._msg = new MessageBll(this.conn);
				msg = this._msg;
			}
			else
			{
				msg = this._msg;
			}
			return msg;
		}
	}
	protected Email m_email
	{
		get
		{
			Email email;
			if (this._email == null)
			{
				this._email = new Email();
				email = this._email;
			}
			else
			{
				email = this._email;
			}
			return email;
		}
	}
	protected MobileMessage m_mmsg
	{
		get
		{
			MobileMessage mmsg;
			if (this._mmsg == null)
			{
				this._mmsg = new MobileMessage();
				mmsg = this._mmsg;
			}
			else
			{
				mmsg = this._mmsg;
			}
			return mmsg;
		}
	}
	protected void Page_Init(object sender, EventArgs e)
	{
		if (!this.ExistGroup())
		{
			this.WriteErrMsg("", "对不起，该网站的管理员已禁用注册！", "");
		}
		else
		{
			this.SelectRegWay();
			if (this.JustMenberType())
			{
				this.tabMember.Visible = true;
				this.DataBindMenber();
			}
			else
			{
				this.tabMember.Visible = false;
			}
			try
			{
			}
			catch (Exception ex)
			{
				base.WriteTemErrMsg(ex.Message.ToString());
			}
		}
	}
	public string GetShopConfigPath()
	{
		ShopConfigBll shopConfigBll = new ShopConfigBll();
		return shopConfigBll.DataPath;
	}
	public bool JustMenberType()
	{
		int num = 0;
		DataTable dataTable = this.conn.GetDataTable("select * from HL_Group");
		bool result;
		if (dataTable.Rows.Count > 0)
		{
			for (int i = 0; i < dataTable.Rows.Count; i++)
			{
				if (dataTable.Rows[i]["IsShow"].ToString() == "1")
				{
					num++;
				}
			}
			if (num > 0)
			{
				result = true;
				return result;
			}
		}
		result = false;
		return result;
	}
	public bool ExistGroup()
	{
		return this.conn.ExecuteCount("select count(*) from HL_Group") > 0;
	}
	protected void DataBindMenber()
	{
		this.RadioMemberList.DataTextField = "GroupName";
		this.RadioMemberList.DataValueField = "GroupID";
		this.RadioMemberList.DataSource = this.conn.GetDataSet("select GroupName,GroupID from HL_Group where IsShow=1");
		this.RadioMemberList.DataBind();
		if (this.RadioMemberList.Items.Count > 0)
		{
			this.RadioMemberList.Items[0].Selected = true;
		}
	}
	protected void SelectRegWay()
	{
		if (this.config["EnableReg"].ToString() != "1")
		{
			this.WriteErrMsg("", Language.Get("PassPort/CloseReg"), "");
		}
		if (Fetch.Get("Action") == "CheckReg")
		{
			this.CheckUserReg();
		}
		if (Fetch.Get("Action") == "CheckCode")
		{
			this.CheckCertifyCode();
		}
		if (this.isOutWebPost())
		{
			this.isOutWebSite = 1;
			this.InitOutReg();
			base.Response.End();
		}
		if (base.user.CheckUserLogin())
		{
			this.WriteErrMsg("", Language.Get("PassPort/isLogin"), "");
		}
		if (this.isPost())
		{
			this.InitReg();
			base.Response.End();
		}
		if (!string.IsNullOrEmpty(this.config["RegPageSet"].ToString()))
		{
			if (this.config["RegPageSet"].ToString().ToLower() != Fetch.CurrentUrl.ToLower())
			{
				base.Response.Redirect(this.config["RegPageSet"].ToString());
				base.Response.End();
			}
		}
	}
	protected void InitOutReg()
	{
		if (this.config["HLIntegration"].ToString() != "1")
		{
			this.WriteErrMsg("", Language.Get("Common/PoassPortNotStart"), "");
		}
		string orPost = Fetch.GetOrPost("Code");
		Encoding encoding = Encoding.GetEncoding("gb2312");
		if (orPost != string.Empty)
		{
			if (orPost.ToLower() == "utf-8" || orPost.ToLower() == "utf8")
			{
				encoding = Encoding.UTF8;
			}
		}
		this.RegUserName = Fetch.GetOrPost("UserName", encoding);
		string text = HttpUtility.UrlDecode(this.RegUserName, encoding);
		this.RegPassword = Fetch.GetOrPost("Password");
		this.RegQuestion = Fetch.GetOrPost("Question", encoding);
		this.RegAnswer = Fetch.GetOrPost("Answer");
		this.RegEmail = Fetch.GetOrPost("Email");
		this.RegOther = Fetch.GetOrPost("Other");
		if (Fetch.GetOrPost("Sex") != string.Empty)
		{
			this.RegSex = Convert.ToInt32(Fetch.GetOrPost("Sex"));
		}
		this.m_ComeUrl = Text.GetComeUrl(Fetch.GetOrPost("ComeUrl"));
		string orPost2 = Fetch.GetOrPost("Sign");
		string cstr = this.Md5(text.ToLower() + this.RegPassword + this.config["SecurityKey"].ToString(), 32);
		if (!Text.CheckMd5Text(orPost2, cstr))
		{
			this.WriteErrMsg("", Language.Get("PassPort/VerifiyErr"), "");
		}
		this.O_RegPassword = this.RegPassword;
		this.O_RegAnswer = this.RegAnswer;
		this.RegUser();
	}
	protected void InitReg()
	{
		this.RegUserName = Fetch.Post("H_UserName");
		this.RegQuestion = Fetch.Post("H_UserQuestion");
		this.RegPassword = Fetch.Post("H_UserPassword");
		this.Regpwd = this.RegPassword;
		this.O_RegPassword = this.RegPassword;
		this.RegPassword = this.Md5(this.RegPassword, 32);
		this.O_RegAnswer = Fetch.Post("H_UserAnswer");
		if (this.O_RegAnswer != string.Empty)
		{
			this.RegAnswer = this.Md5(this.O_RegAnswer, 32);
		}
		else
		{
			this.RegAnswer = "";
		}
		this.RegEmail = Fetch.Post("H_UserEmail");
		this.RegSex = Convert.ToInt32(Fetch.Post("H_UserSex"));
		this.RegOther = Fetch.GetOrPost("H_Other");
		if (this.config["EnableRegCode"].ToString() == "1")
		{
			if (!this.CheckValidateCode(Fetch.Post("CheckCode")))
			{
				this.WriteErrMsg("", Language.Get("PassPort/CheckCodeErr"), "");
			}
		}
		this.m_ComeUrl = Text.GetComeUrl(Fetch.GetOrPost("H_ComeUrl"));
		this.RegUser();
	}
	protected bool isOutWebPost()
	{
		return Fetch.Post("UserName") != string.Empty && Fetch.Post("Password") != string.Empty && Fetch.Post("Email") != string.Empty;
	}
	protected bool isPost()
	{
		return Fetch.Post("H_UserName") != string.Empty && Fetch.Post("H_UserPassword") != string.Empty && Fetch.Post("H_UserEmail") != string.Empty;
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		this.H_ComeUrl.Value = (this.m_ComeUrl = Text.GetComeUrl(Fetch.GetOrPost("ComeUrl")));
		if (!base.IsPostBack)
		{
			this.InitPage();
		}
	}
	protected void RegUser()
	{
		if (this.m_User.CheckUserExist("UserName", this.RegUserName))
		{
			this.WriteErrMsg("", Language.Get("PassPort/UserNameExist"), "");
		}
		if (this.CheckBanUserRegName(this.RegUserName))
		{
			this.WriteErrMsg("", Language.Get("PassPort/NameRestric"), "");
		}
		string text = this.config["RegNameSet"].ToString();
		if (text != "0" && text != null)
		{
			string text2 = text;
			if (text2 != null)
			{
				if (!(text2 == "1"))
				{
					if (!(text2 == "2"))
					{
						if (text2 == "3")
						{
							if (Text.CheckChineaseName(this.RegUserName))
							{
								this.WriteErrMsg("", Language.GetAdminMsg("PassPort/NameCn"), "");
							}
						}
					}
					else
					{
						if (!Text.CheckChineaseName(this.RegUserName))
						{
							this.WriteErrMsg("", Language.GetAdminMsg("PassPort/NameEn"), "");
						}
					}
				}
				else
				{
					if (Text.IsNumber(this.RegUserName))
					{
						this.WriteErrMsg("", Language.GetAdminMsg("PassPort/NameNumber"), "");
					}
				}
			}
		}
		int min = 1;
		int max = 50;
		try
		{
			min = Convert.ToInt32(this.config["RegNameMin"].ToString());
			max = Convert.ToInt32(this.config["RegNameMax"].ToString());
		}
		catch
		{
		}
		if (!this.CheckNameLength(this.RegUserName, min, max))
		{
			this.WriteErrMsg("", Language.Get("PassPort/NameLengErr"), "");
		}
		if (this.isOutWebSite == 0)
		{
			if (this.O_RegPassword != Fetch.GetOrPost("RePassword"))
			{
				this.WriteErrMsg("", Language.Get("PassPort/rePasswordErr"), "");
			}
		}
		if (this.O_RegPassword.Length < 2)
		{
			this.WriteErrMsg("", Language.Get("PassPort/PasswordLengErr"), "");
		}
		if (this.checkpassword(this.O_RegPassword) == 0 && this.checkpassword(this.O_RegPassword) != -1)
		{
			this.WriteErrMsg("", "密码长度不对", "");
		}
		else
		{
			if (this.checkpassword(this.O_RegPassword) == 1 && this.checkpassword(this.O_RegPassword) != -1)
			{
				this.WriteErrMsg("", "密码不能全部是字符", "");
			}
			else
			{
				if (this.checkpassword(this.O_RegPassword) == 2 && this.checkpassword(this.O_RegPassword) != -1)
				{
					this.WriteErrMsg("", "密码不能全部是数字", "");
				}
				else
				{
					if (this.checkpassword(this.O_RegPassword) == 3 && this.checkpassword(this.O_RegPassword) != -1)
					{
						this.WriteErrMsg("", "您设置的密码有误，不能设置连续相同的字符或数字", "");
					}
					else
					{
						if (this.checkpassword(this.O_RegPassword) == 4 || this.checkpassword(this.O_RegPassword) == 5 || this.checkpassword(this.O_RegPassword) == 6)
						{
							this.WriteErrMsg("", "您设置的密码有误，密码应该由6-16个英文字母、数字或符号组成!", "");
						}
						else
						{
							if (this.config["RegIPOnce"].ToString() != string.Empty && this.config["RegIPOnce"].ToString() != "0")
							{
								int num = 0;
								try
								{
									num = Convert.ToInt32(this.config["RegIPOnce"].ToString());
								}
								catch
								{
								}
								if (num > 0)
								{
									DataTable dataTable = this.conn.GetDataTable("Select Top 1 RegIP,RegTime From [HL_User] Where RegIP='" + Fetch.UserIp + "' Order By UserID Desc");
									if (dataTable.Rows.Count > 0)
									{
										if (Convert.ToDateTime(dataTable.Rows[0]["RegTime"].ToString()).AddMinutes((double)num) > DateTime.Now)
										{
											this.WriteErrMsg("", Language.Get("PassPort/IPRegTime", num.ToString()), "");
										}
									}
								}
							}
							if (string.IsNullOrEmpty(this.RegEmail))
							{
								this.WriteErrMsg("", Language.Get("PassPort/EmailNull"), "");
							}
							if (!Text.CheckEmail(this.RegEmail))
							{
								this.WriteErrMsg("", Language.Get("PassPort/EmailErr"), "");
							}
							AppSetings appSetings = new AppSetings();
							if (this.config["EnableEmailOnce"].ToString() == "0")
							{
								if (appSetings.GetConfig("UC_ONorOFF") == "ON")
								{
									int num2 = Func.uc_user_checkemail(this.RegEmail);
									if (num2 == -4)
									{
										this.WriteErrMsg("", "Email 格式有误", "");
									}
									else
									{
										if (num2 == -5)
										{
											this.WriteErrMsg("", "Email 不允许注册", "");
										}
										else
										{
											if (num2 == -6)
											{
												this.WriteErrMsg("", "Email已经存在", "");
											}
										}
									}
								}
								else
								{
									if (this.m_User.CheckUserExist("Email", this.RegEmail))
									{
										this.WriteErrMsg("", Language.Get("PassPort/EmailExist"), "");
									}
								}
							}
							if (this.config["RegBanEmail"].ToString() != "")
							{
								string text3 = this.config["RegBanEmail"].ToString();
								if (text3 != string.Empty)
								{
									string[] array = text3.Split(new char[]
									{
										','
									});
									bool flag = false;
									for (int i = 0; i < array.Length; i++)
									{
										if (this.RegEmail.Substring(this.RegEmail.IndexOf("@") + 1).ToLower() == array[i].Trim().ToLower())
										{
											flag = true;
											break;
										}
									}
									if (flag)
									{
										this.WriteErrMsg("", Language.Get("PassPort/EmailRestric"), "");
									}
								}
							}
							int num3 = Convert.ToInt32(this.config["RegPresent1"].ToString());
							int num4 = Convert.ToInt32(this.config["RegPresent2"].ToString());
							int point = Convert.ToInt32(this.config["RegPresent3"].ToString());
							int num5 = Convert.ToInt32(this.config["RegPresent4"].ToString());
							int num6 = 1;
							if (this.JustMenberType())
							{
								num6 = int.Parse(Fetch.Post("RadioMemberList"));
							}
							int isLocked = 0;
							string text4 = "";
							string text5 = this.config["RegConfirm"].ToString();
							string text2 = text5;
							if (text2 != null)
							{
								if (!(text2 == "1"))
								{
									if (!(text2 == "2"))
									{
										if (!(text2 == "3"))
										{
											if (text2 == "4")
											{
												isLocked = 1;
											}
										}
										else
										{
											this.MobilePhone = Fetch.Post("MobilePhone");
											if (this.MobilePhone == string.Empty)
											{
												this.WriteErrMsg("", Language.Get("PassPort/NeadMobile"), "");
											}
											if (!Text.CheckMobilePhone(this.MobilePhone))
											{
												this.WriteErrMsg("", Language.Get("PassPort/MobileErr"), "");
											}
											isLocked = 1;
											text4 = this.MakePassword();
										}
									}
									else
									{
										isLocked = 1;
										text4 = this.MakePassword();
									}
								}
							}
							if (this.conn.ExecuteCount("select count(Locked) from HL_Group where GroupID=" + num6 + " and Locked=1") > 0)
							{
								isLocked = 1;
							}
							this.GetOptionalParam("HL_UserInfo", "MobilePhone", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "Country", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "City", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "ZipCode", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "Address", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "ComeFrom", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "Birthday", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "Nation", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "TrueName", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "IDCard", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "Eductation", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "GraduteSchool", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "ICQ", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "OICQ", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "MSN", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "HomePage", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "HomePhone", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "Fax", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "Taobaowangwang", DbType.String);
							this.GetOptionalParam("HL_UserInfo", "IDCardPhoto", DbType.String);
							if (text4 != string.Empty)
							{
								this.fields += "@CheckNum,";
								this.al.Add(this.conn.CreateParameter("@CheckNum", DbType.String, text4));
							}
							if (num4 > 0)
							{
								this.fields += "@Ticket,";
								this.al.Add(this.conn.CreateParameter("@Ticket", DbType.Int32, num4));
							}
							if (num3 > 0)
							{
								this.fields += "@GoldCoin,";
								this.al.Add(this.conn.CreateParameter("@GoldCoin", DbType.Int32, num3));
							}
							if (this.al != null && this.fields != "")
							{
								this.fields = this.fields.Remove(this.fields.Length - 1);
								this.param = new IDbDataParameter[this.al.Count];
								this.al.CopyTo(this.param, 0);
							}
							if (this.al_infr != null && this.fields_infr != "")
							{
								this.fields_infr = this.fields_infr.Remove(this.fields_infr.Length - 1);
								this.param_infr = new IDbDataParameter[this.al_infr.Count];
								this.al_infr.CopyTo(this.param_infr, 0);
							}
							bool flag2 = false;
							if (appSetings.GetConfig("UC_ONorOFF") == "ON")
							{
								DataTable dataTable = DbHelperSQL.GetDataTable("select top 1 SerialNumber   from HL_User  order by UserID Desc");
								string serialNumber;
								if (dataTable.Rows[0]["SerialNumber"] is DBNull || dataTable.Rows.Count <= 0)
								{
									serialNumber = "1000000";
								}
								else
								{
									serialNumber = (Convert.ToInt64(dataTable.Rows[0]["SerialNumber"]) + 1L).ToString();
								}
								int num7 = Func.uc_user_register(this.RegUserName, this.Regpwd, this.RegEmail);
								if (num7 == -1)
								{
									this.WriteErrMsg("", "用户名不合法", "");
								}
								else
								{
									if (num7 == -2)
									{
										this.WriteErrMsg("", "包含不允许注册的词语", "");
									}
									else
									{
										if (num7 == -3)
										{
											this.WriteErrMsg("", "用户名已经存在", "");
										}
										else
										{
											if (num7 == -4)
											{
												this.WriteErrMsg("", "Email 格式有误", "");
											}
											else
											{
												if (num7 == -5)
												{
													this.WriteErrMsg("", "Email 不允许注册", "");
												}
												else
												{
													if (num7 == -6)
													{
														this.WriteErrMsg("", "该 Email 已经被注册", "");
													}
													else
													{
														flag2 = this.m_User.AddUser(serialNumber, num7, this.RegUserName, this.RegPassword, this.RegEmail, this.RegQuestion, this.RegAnswer, this.RegSex, num6, num5, isLocked, point, Fetch.UserIp, this.fields, this.fields_infr, this.param, this.param_infr);
													}
												}
											}
										}
									}
								}
								if (num5 > 0)
								{
									UserExpAction userExpAction = new UserExpAction(this.conn);
									userExpAction.AddUserExp(num7, (long)num5, 1, Language.Get("PassPort/AddUserExp"), new Conn[0]);
								}
								string script = Func.uc_user_synlogin(num7);
								base.ClientScript.RegisterStartupScript(base.GetType(), "synlogin", script);
							}
							else
							{
								DataTable dataTable = DbHelperSQL.GetDataTable("select top 1 max(UserID) as UserID,(select top 1 b.SerialNumber from HL_User as b order by b.UserID Desc) as SerialNumber  from dbo.HL_User");
								int userID;
								if (dataTable.Rows[0]["UserID"] is DBNull || dataTable.Rows.Count <= 0)
								{
									userID = 1;
								}
								else
								{
									userID = Convert.ToInt32(dataTable.Rows[0]["UserID"]) + 1;
								}
								string serialNumber;
								if (dataTable.Rows[0]["SerialNumber"] is DBNull || dataTable.Rows.Count <= 0)
								{
									serialNumber = "1000000";
								}
								else
								{
									serialNumber = (Convert.ToInt32(dataTable.Rows[0]["SerialNumber"]) + 1).ToString();
								}
								flag2 = this.m_User.AddUser(serialNumber, userID, this.RegUserName, this.RegPassword, this.RegEmail, this.RegQuestion, this.RegAnswer, this.RegSex, num6, num5, isLocked, point, Fetch.UserIp, this.fields, this.fields_infr, this.param, this.param_infr);
								if (num5 > 0)
								{
									UserExpAction userExpAction = new UserExpAction(this.conn);
									userExpAction.AddUserExp(userID, (long)num5, 1, Language.Get("PassPort/AddUserExp"), new Conn[0]);
								}
							}
							if (!flag2)
							{
								this.WriteErrMsg("", Language.Get("PassPort/RegFail"), "");
							}
							string smtpserver = this.config["MailSmtpServer"].ToString();
							string mailuser = this.config["MailServerUserName"].ToString();
							string mailpassword = this.config["MailServerPassWord"].ToString();
							string mailFrom = this.config["MailServerFrom"].ToString();
							string text6 = this.config["MailObject"].ToString();
							string text7 = this.config["RegEmailContent"].ToString();
							text6 = text6.Replace("{$SiteName$}", this.config["SiteName"].ToString());
							text2 = text5;
							if (text2 != null)
							{
								if (!(text2 == "1"))
								{
									if (!(text2 == "2"))
									{
										if (!(text2 == "3"))
										{
											if (text2 == "4")
											{
												this.m_msg.AddMessage(Language.Get("Mobile/UserName"), "Users", Language.Get("Admin/Mobile/UserClass"), "<b>" + this.RegUserName + "</b> " + Language.Get("Admin/Mobile/Cfin"), 0, 0, 1, 0, Language.Get("Admin/Mobile/Admin"), "", 1);
											}
										}
										else
										{
											text7 = text7.Replace("{$CheckNum$}", text4);
											text7 = text7.Replace("{$UserName$}", this.RegUserName);
											text7 = text7.Replace("{$Password$}", this.O_RegPassword);
											text7 = text7.Replace("{$Question$}", this.RegQuestion);
											text7 = text7.Replace("{$Answer$}", this.O_RegAnswer);
											text7 = text7.Replace("{$SiteURL$}", this.config["SiteUrl"].ToString());
											text7 = text7.Replace("{$SiteName$}", this.config["SiteName"].ToString());
											this.m_mmsg.Send(this.MobilePhone, text7, this.RegUserName);
										}
									}
									else
									{
										text7 = text7.Replace("{$CheckNum$}", text4);
										text7 = text7.Replace("{$UserName$}", this.RegUserName);
										text7 = text7.Replace("{$Password$}", this.O_RegPassword);
										text7 = text7.Replace("{$Question$}", this.RegQuestion);
										text7 = text7.Replace("{$Answer$}", this.O_RegAnswer);
										text7 = text7.Replace("{$SiteURL$}", this.config["SiteUrl"].ToString());
										text7 = text7.Replace("{$SiteName$}", this.config["SiteName"].ToString());
										this.m_email.SendEmail(smtpserver, mailuser, mailpassword, mailFrom, text7, this.RegEmail, text6);
									}
								}
								else
								{
									text7 = text7.Replace("{$UserName$}", this.RegUserName);
									text7 = text7.Replace("{$Password$}", this.O_RegPassword);
									text7 = text7.Replace("{$Question$}", this.RegQuestion);
									text7 = text7.Replace("{$Answer$}", this.O_RegAnswer);
									text7 = text7.Replace("{$SiteURL$}", this.config["SiteUrl"].ToString());
									text7 = text7.Replace("{$SiteName$}", this.config["SiteName"].ToString());
									this.m_email.SendEmail(smtpserver, mailuser, mailpassword, mailFrom, text7, this.RegEmail, text6);
								}
							}
							if (this.config["RegSendMsg"].ToString() == "1")
							{
								string text8 = this.config["RegMsgContent"].ToString();
								if (text8 != string.Empty)
								{
									text8 = text8.Replace("{$UserName$}", this.RegUserName);
									text8 = text8.Replace("{$SiteName$}", this.config["SiteName"].ToString());
									text8 = text8.Replace("{$SiteUrl$}", this.config["SiteUrl"].ToString());
									text8 = text8.Replace("{$Password$}", this.O_RegPassword);
									text8 = text8.Replace("{$Question$}", this.RegQuestion);
									text8 = text8.Replace("{$Answer$}", this.O_RegAnswer);
								}
								this.m_msg.AddMessage(Language.Get("Admin/Mobile/SAdmin"), "Users", Language.Get("Admin/Mobile/Syst"), text8, 0, 0, 1, 0, this.RegUserName, "", 1);
							}
							if (this.config["RegURLSet"].ToString() == string.Empty)
							{
								text2 = this.config["RegURLSet"].ToString();
								if (text2 != null)
								{
									if (!(text2 == "1"))
									{
										if (text2 == "2")
										{
											this.m_ComeUrl = this.config["RegURL"].ToString();
										}
									}
									else
									{
										this.m_ComeUrl = this.config["SiteUrl"].ToString();
									}
								}
							}
							if (this.m_ComeUrl == string.Empty)
							{
								this.m_ComeUrl = this.config["SiteUrl"].ToString();
							}
							base.user.UserName = this.RegUserName;
							base.user.Password = this.RegPassword;
							base.user.UserLogin();
							this.conn.Execute("insert into HL_UserInfo (UserID) values(" + base.user.UserID + ")");
							if (this.config["HLIntegration"].ToString() == "1")
							{
								new Integrate(this.conn)
								{
									ComeUrl = this.m_ComeUrl,
									sendEnd = Language.Get("PassPort/RegSuccess").Replace("{$ComeUrl}", this.m_ComeUrl) + ";top.location.href='" + this.m_ComeUrl + "';"
								}.Send("Reg", this.RegUserName, this.RegPassword, this.RegEmail, this.RegQuestion, this.RegAnswer, 0, this.O_RegPassword, this.RegOther);
							}
							else
							{
								string text9 = "注册成功！欢迎您的加入";
								if (text5 == "2")
								{
									text9 += Language.Get("PassPort/SendCheckEmail");
								}
								if (text5 == "3")
								{
									text9 += Language.Get("PassPort/SendCheckMobilePhone");
								}
								if (text5 == "4")
								{
									text9 += Language.Get("PassPort/WaifCheck");
								}
								this.WriteSuccessMsg("", text9, this.m_ComeUrl);
							}
						}
					}
				}
			}
		}
	}
	protected void InitPage()
	{
		string text = this.config["CloseMessage"].ToString();
		string newValue = this.config["SiteName"].ToString();
		string text2 = RegProtocal.Get();
		if (text2.Contains("{$SiteName$}"))
		{
			text2 = text2.Replace("{$SiteName$}", newValue);
		}
		string text3 = this.config["EnableEmailOnce"].ToString();
		string a = this.config["EnablePasswordCheck"].ToString();
		string a2 = this.config["RegAnswerCheck"].ToString();
		string text4 = this.config["RegQuestion"].ToString();
		string a3 = this.config["RegAnswer"].ToString();
		string a4 = this.config["EnableRegCode"].ToString();
		string text5 = this.config["RegNameSet"].ToString();
		if (a4 == "0")
		{
			this.EnableRegCheckCode.Visible = false;
		}
		else
		{
			this.EnableRegCheckCode.Visible = true;
		}
		this.H_UserQuestion.DataSource = this.GetQuestionList();
		this.H_UserQuestion.DataBind();
		DateTime now = DateTime.Now;
		this.m_ComeUrl = Fetch.GetOrPost("ComeUrl");
		if (this.m_ComeUrl == string.Empty)
		{
			try
			{
				this.m_ComeUrl = base.Request.UrlReferrer.ToString();
			}
			catch
			{
			}
		}
		if (this.m_ComeUrl != string.Empty)
		{
			this.H_ComeUrl.Value = this.m_ComeUrl.Replace("&", "---");
		}
		try
		{
			int num = Convert.ToInt32(this.config["RegNameMin"]);
			int num2 = Convert.ToInt32(this.config["RegNameMax"]);
		}
		catch
		{
		}
		if (a2 == "1" && a3 != "" && text4 != "")
		{
			this.RegProtected.Visible = true;
			this.RegCheckQuestion.Text = text4;
		}
		else
		{
			this.RegProtected.Visible = false;
		}
		if (a == "1")
		{
			this.ShowPasswordCheck.Visible = true;
		}
		else
		{
			this.ShowPasswordCheck.Visible = false;
		}
		this.RePassword.Attributes.Add("onpaste", "return false");
		this.RePassword.Attributes.Add("oncontextmenu", "return false");
	}
	protected bool CheckBanUserRegName(string username)
	{
		string text = this.config["RegBanName"].ToString();
		bool result;
		if (text == string.Empty)
		{
			result = false;
		}
		else
		{
			string[] array = text.Split(new char[]
			{
				','
			});
			for (int i = 0; i < array.Length; i++)
			{
				if (username.ToLower().Contains(array[i].Trim().ToLower()))
				{
					result = true;
					return result;
				}
			}
			result = false;
		}
		return result;
	}
	protected void GetOptionalParam(string tablename, string paramname, DbType db_type)
	{
		if (tablename == string.Empty)
		{
			tablename = "hl_user";
		}
		if (tablename.ToLower() == "hl_userinfo")
		{
			if (Fetch.Post(paramname) != string.Empty)
			{
				this.fields_infr = this.fields_infr + "@" + paramname + ",";
				this.al_infr.Add(this.conn.CreateParameter("@" + paramname, db_type, Fetch.Post(paramname)));
			}
		}
		else
		{
			if (Fetch.Post(paramname) != string.Empty)
			{
				this.fields = this.fields + "@" + paramname + ",";
				this.al.Add(this.conn.CreateParameter("@" + paramname, db_type, Fetch.Post(paramname)));
			}
		}
	}
	protected void CheckUserReg()
	{
		string text = Text.ReplaceBadChar(Fetch.Get("UserName"));
		AppSetings appSetings = new AppSetings();
		bool flag;
		if (appSetings.GetConfig("UC_ONorOFF") == "ON")
		{
			int num = Func.uc_user_checkname(text);
			flag = (num == 1);
		}
		else
		{
			flag = !this.CheckBanUserRegName(text);
			if (flag)
			{
				UserBll userBll = new UserBll(this.conn);
				flag = !userBll.CheckUserExist("UserName", text);
				flag = !userBll.CheckUserExist("UserName", text);
			}
		}
		base.Response.Write(flag);
		this.Finish();
		base.Response.End();
	}
	public void CheckCertifyCode()
	{
		base.Response.Write(this.CheckValidateCode(Fetch.Get("ValidateCode")));
		base.Response.End();
	}
	public int checkpassword(string password)
	{
		Regex regex = new Regex("^[A-Za-z]+$");
		int result;
		if (regex.IsMatch(password))
		{
			result = 1;
		}
		else
		{
			if (Regex.IsMatch(password, "^([+-]?)\\d*$"))
			{
				result = 2;
			}
			else
			{
				char[] array = password.ToCharArray();
				if (password.Length < 6 || password.Length > 16)
				{
					result = 0;
				}
				else
				{
					int i;
					for (i = 0; i < password.Length; i++)
					{
						if (array[0] != array[i])
						{
							break;
						}
					}
					if (i == array.Length)
					{
						result = 3;
					}
					else
					{
						string text = "01234567890";
						if (text.IndexOf(password) != -1)
						{
							result = 4;
						}
						else
						{
							string text2 = "abcdefghijklmnopqrstuvwxyz";
							if (text2.IndexOf(password) != -1)
							{
								result = 5;
							}
							else
							{
								string text3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
								if (text3.IndexOf(password) != -1)
								{
									result = 6;
								}
								else
								{
									result = -1;
								}
							}
						}
					}
				}
			}
		}
		return result;
	}
}
